<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app"></div>
  <div id="app1"></div>
  <div id="app2"></div>
  <script src="../node_modules/@vue/reactivity/dist/reactivity.global.js"></script>
  <script>
    const { toRef, reactive, toRefs, effect } = VueReactivity;
    
    const state = reactive({name: 'Jerry'});

    const app = document.querySelector('#app');
    
    effect(() => {
      app.innerHTML = state.name;
    })
    
    setTimeout(() => {
      state.name = 'Tom2'
    }, 2000);


    const refO = toRef(state, 'name');
    const app1 = document.querySelector('#app1');
    effect(() => {
      app1.innerHTML = refO.value;
    })
    
    setTimeout(() => {
      state.name = 'Tom'
    }, 1000);




    const state2 = reactive({name: 'Jerry', age: 23});
    const {name, age} = toRefs(state2);
    const app2 = document.querySelector('#app2');
    effect(() => {
      app2.innerHTML = name.value + age.value;
    })
    
    setTimeout(() => {
      state2.age = 1
    }, 1000);
    </script>
</body>
</html>